#include "stdafx.h"
#include "_Border.h"
#include "_GraphLayout.h"
#include <gl/gl.h>
#include <gl/glu.h>


/*
*  @brief Constructor
*/
_Border::_Border(_GraphLayout& Layout):
    m_Layout(Layout)
{
    m_Size        = 1;
    m_Visible     = true;
    m_Color       = RGB(0, 0, 0);
}

/*
*  @brief Destructor
*/
_Border::~_Border(void)
{
}

/*
*  @brief Draws the border
*/
void _Border::draw()
{
    // Draw to complete control window
    glViewport(0, 0, m_Layout.m_ControlRect.Width(), m_Layout.m_ControlRect.Height());
    // Set the coordinate system
    glLoadIdentity();
    gluOrtho2D(0, m_Layout.m_ControlRect.Width(), 0, m_Layout.m_ControlRect.Height());
    // Draw the border rects
    glColor3i(GET_GLINT_R(m_Color), GET_GLINT_G(m_Color), GET_GLINT_B(m_Color));
    glRectd(0, 0, m_Layout.m_ControlRect.Width(), m_Size);
    glRectd(0, m_Layout.m_ControlRect.Height(), m_Layout.m_ControlRect.Width(), m_Layout.m_ControlRect.Height() - m_Size);
    glRectd(0, 0, m_Size, m_Layout.m_ControlRect.Height());
    glRectd(m_Layout.m_ControlRect.Width(), 0, m_Layout.m_ControlRect.Width() - m_Size, m_Layout.m_ControlRect.Height());
}


/*
*  @brief Sets the size of the border
*  @param Size - new size in pixels
*/
void _Border::setSize(_u32 Size)
{
    m_Size = Size;
}

/*
*  @brief Sets the visibility of the border
*  @param Visible - New visibility
*/
void _Border::setVisible(bool Visible)
{
    m_Visible = Visible;
}

/*
*  @brief Returns the size of the border
*  @returns Size in pixels
*/
_u32 _Border::getSize()
{
    return m_Size;
}

/*
*  @brief Returns if the graph is visible or not
*  @returns true or false
*/
bool _Border::isVisible()
{
    return m_Visible;
}

/*
*  @brief Sets the color of the border
*  @param Color - New border color
*/
void _Border::setColor(COLORREF Color)
{
    m_Color = Color;
}

/*
*  @brief Returns the color of the border
*  @returns Color as RGB color reference
*/
COLORREF _Border::getColor()
{
    return m_Color;
}

